import {useEffect, useState} from 'react'
import {useParams} from 'react-router-dom'
import Base64 from '@/utils/base64'

export const useProductId = ():string => {
  const [product_id, setProduct_id] = useState<string>("")
  const params = useParams<{
    id: string
  }>()

  useEffect(() => {
    const base:Base64 = new Base64()
    const decode:string = base.decode( params.id! )
    const arr:[string, string] = decode.split("=")
    setProduct_id(arr[1])
  }, [product_id])


  return product_id
}

